package com.auto.video.tv.presenter;

import android.content.Context;

import com.auto.video.tv.MainActivity;
import com.auto.video.tv.model.IVideoModel;
import com.auto.video.tv.model.VideoModel;
import com.xin.auto.lib.base.UsbHelper;
import com.xin.auto.lib.base.adloopvideoplayer.view.IView;

import java.util.List;

import me.jahnen.libaums.core.fs.UsbFile;

/**
 * Created by demo on 2017/3/23 0023
 */
public class VideoPresenter implements IVideoPresenter, OnVideoListener {
    private IView mView;
    private IVideoModel mModel;

    private Context mContext;
    private UsbHelper mUsbHelper;

    public VideoPresenter(IView view) {
        this.mView = view;
        mContext = (MainActivity) view;
        mModel = new VideoModel();
    }

    @Override
    public void getData(UsbHelper usbHelper) {
        mModel.loadVideo(mContext, usbHelper, this);
        mUsbHelper = usbHelper;
    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void onSuccess(List<UsbFile> result) {
        mView.showData(result);
    }

    @Override
    public void onFail() {
        // 获取失败 重新获取
        getData(mUsbHelper);
    }
}
